package com.jxin.web.err;

import com.jxin.web.entity.HttpRsp;
import com.jxin.web.tmp.ControllerTemp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * web异常
 * @author Jxin
 * @version 1.0
 * @since 2020/1/13 20:01
 */
@ControllerAdvice
@Slf4j
public class WebException extends ControllerTemp {
    /**web异常消息模板*/
    private static final String GLOBAL_ERR_TEMP = "[web层捕获异常],msg: {}";

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public HttpRsp exceptionHandler(Exception e) {
        log.warn(GLOBAL_ERR_TEMP, e.getMessage(), e);
        return createFaild();
    }
}
